{% extends base_template %}
{% load seahub_tags avatar_tags i18n %}
{% load url from future %}

{% block sub_title %}{% trans "History" %} - {% endblock %}

{% block main_panel %}
<h2>{{ u_filename }}{% trans "'s Version History" %}</h2>
<p class="tip">{% trans "Tip:a new version will be generated after each modification, and you can restore the file to a previous version." %}</p>

<p class="path">
{% trans 'Current Path:' %}
{% for name, link in zipped %}
{% if not forloop.last %}
<a href="{{ SITE_ROOT }}repo/{{ repo.id }}/?p={{ link|urlencode }}">{{ name }}</a> /    
{% else %}
<a href="{{ SITE_ROOT }}repo/{{ repo.id }}/files/?p={{ path|urlencode }}">{{ name }}</a>
{% endif %}
{% endfor %}
</p>
<div class="commit-list-outer-container">
    <div class="commit-list-inner-container">
        <table class="commit-list">
            <tr>
                <th width="30%" class="time">{% trans 'Time' %}</th>
                <th width="20%">{% trans 'Modifier' %}</th>
                <th width="20%">{% trans 'Size' %}</th>
                <th width="30%">{% trans 'Operations' %}</th>
            </tr>
            {% for commit in commits %}
            <tr>
                <td class="time">
                    {{ commit.props.ctime|translate_seahub_time }}
                    {% if commit.is_current_version %}
                    {% trans '(current version)' %}
                    {% endif %}

                    {% if commit.rev_renamed_old_path %}
                    <br /><span class="tip">{% blocktrans with old_path=commit.rev_renamed_old_path %}(Renamed or moved from {{ old_path }}){% endblocktrans %}</span>
                    {% endif %}
                </td>

                {% if commit.creator_name %}
                <td>
                    {% avatar commit.creator_name 16 %}
                    <a href="{% url 'user_profile' commit.creator_name|id_or_email %}" class="vam">{{ commit.creator_name|email2nickname }}</a>
                </td>
                {% else %}
                <td>{% trans 'Unknown' %}</td>
                {% endif %}

                <td>{{ commit.rev_file_size|filesizeformat }} </td>
                <td>
                    {% if commit.id != repo.head_cmmt_id %}
                    <a href="{{ SITE_ROOT }}repo/revert_file/{{ repo.id }}/?commit={{ commit.id }}&p={{commit.path|urlencode}}&from=file_revisions" class="op vh">{% trans 'Restore' %}</a>
                    {% endif %}
                    <a href="{{ SITE_ROOT }}repo/file_revisions/{{ repo.id }}/?commit={{ commit.id }}&p={{commit.path|urlencode}}&op=download" class="op vh">{% trans 'Download' %}</a>
                    <a href="{% url 'view_history_file' repo.id %}?obj_id={{ commit.rev_file_id }}&commit_id={{ commit.id }}&p={{commit.path|urlencode}}" class="op vh">{% trans 'View' %}</a>
                    {% if can_compare and not forloop.last %}
                    <a href="{% url 'text_diff' repo.id %}?p={{commit.path|urlencode}}&commit={{commit.id}}" class="op vh">{% trans 'Diff' %}</a>
                    {% endif %}
                </td>
            </tr>
            {% endfor %}
        </table>
    </div>
</div>
{% endblock %}
